package com.basiclib.utils

import android.content.Context
import android.os.Looper
import org.jetbrains.anko.connectivityManager

fun isMainThread(): Boolean = Looper.myLooper() == Looper.getMainLooper()
public fun isNetworkAvaliable(ctx: Context?): Boolean {
    if (ctx == null) {
        return false
    }
    val cm = ctx.connectivityManager
    return if (cm != null) {
        val net = cm.activeNetworkInfo
        net != null && net.isAvailable && net.isConnected
    } else {
        false
    }
}